#include<iostream>
#include<vector>
using namespace std;

long long ans[10000]={0};
//2 3 5
//1, 2, 3, 4, 5, 6, 8, 9, 10, 12

int chounumber(int n){
    if(n<7)
        return n;
    int index_2=0,index_3=0,index_5=0;
    int t2=0,t3=0,t5=0;
    vector<int> dp(n);
    dp[0]=1;
    for(int i=1;i<n;i++){
        t2=dp[index_2]*2;
        t3=dp[index_3]*3;
        t5=dp[index_5]*5;
        dp[i]=min(t2,min(t3,t5));

        if(dp[i]==t2) index_2++;
        if(dp[i]==t3) index_3++;
        if(dp[i]==t5) index_5++;

    }
    return dp[n-1];
}



int main(){

    int T;
    cin>>T;
    long long number=0;
    for(int i=0;i<T;i++){
        cin>>number;
        ans[i]=chounumber(number);
    }
    for(int i=0;i<T;i++){
        cout<<ans[i]<<"\n";
    }


    return 0;
}
